package edu.gdkm.sql.dao;
import edu.gdkm.sql.pojo.ProductDetail;
import edu.gdkm.sql.pojo.Userinfo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;
@Repository
public interface UserinfoMapper {

    // Create
    @Insert("INSERT INTO userinfo (username, password, name,address,phone) VALUES (#{username}, #{password}, #{name},#{address},#{phone})")
    int insertUserinfo(Userinfo userinfo);

    // Update
    @Update("UPDATE userinfo SET username = #{username}, password = #{password}, name = #{name},address=#{address},phone=#{phone} WHERE id = #{id}")
    int updateUserinfo(Userinfo userinfo);


    // Read
    @Select("SELECT * FROM userinfo WHERE id = #{id}")
    Userinfo getUserinfoById(int id);
    @Select("SELECT * FROM userinfo WHERE username = #{username}")
    Userinfo getUserinfoByUsername(String username);

    @Select("SELECT * FROM userinfo")
    List<Userinfo> getAllUserinfos();

    // Delete
    @Delete("DELETE FROM userinfo WHERE id = #{id}")
    int deleteUserinfo(int id);
}
